package team.zero.lemon.module.sys.web;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import team.zero.lemon.common.authz.annotation.AuthPassport;
import team.zero.lemon.common.persistence.Page;
import team.zero.lemon.common.web.BaseController;
import team.zero.lemon.module.sys.entity.Job;
import team.zero.lemon.module.sys.service.JobService;

import java.util.List;

/**
 * Created by bolin on 2016/11/7.
 */
@Controller
@ResponseBody
@AuthPassport
@RequestMapping(value = "${adminPath}/sys/job", method = {RequestMethod.POST, RequestMethod.GET})
public class JobController  extends BaseController {
    @Autowired
    private JobService jobService;
    @AuthPassport
    @RequestMapping("/query/page")
    public Page<Job> findJob(@RequestBody Job job) {
        return jobService.findPage(job);
    }
    @AuthPassport
    @RequestMapping("/save")
    public int SaveJob(@RequestBody Job job) {
        return jobService.save(job);
    }

    @AuthPassport
    @RequestMapping("/delete/ids")
    public int deleteJob(@RequestBody Job job) {
        return jobService.deleteLogicMulti(job);
    }

    @AuthPassport
    @RequestMapping("/query/id")
    public List<Job> findJobById(@RequestBody int userId) {
        return jobService.findJobByUserId(userId);
    }
    @AuthPassport
    @RequestMapping("/query/tree")
    public List<Job> findJobTree() {
        return jobService.findJobTree();
    }
    @AuthPassport
    @RequestMapping("/query/all")
    public List<Job> findAllJobs() {
        return jobService.findAll();
    }
    @AuthPassport
    @RequestMapping("/query/parameter")
    public List<Job> findJobByParameter(@RequestBody Job job) {
        return jobService.findByParameter(job);
    }
}
